#include "clock.h"

static clock_app_t *local_app;

extern lv_indev_t *my_indev;
extern app_t curr_page;
extern list_app_t list_app;

LV_FONT_DECLARE(digifaw_36);

void remove_clock_app()
{
}

static void my_event_cb(lv_event_t *event)
{
    // 手动释放锁

    if (event->code == LV_EVENT_CLICKED)
    {
        remove_clock_app();
        create_list_app(&list_app);
    }
}

void create_clock_app(clock_app_t *app)
{
    local_app = app;
    curr_page = CLOCK_APP;

    lv_obj_t *scr = lv_obj_create(NULL);

    local_app->label = lv_label_create(scr);
    lv_label_set_text(local_app->label, "2022-04-13\n17:40:01");
    lv_obj_set_style_text_align(local_app->label, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN);
    lv_obj_set_style_text_font(local_app->label, &digifaw_36, LV_PART_MAIN);
    lv_obj_set_style_align(local_app->label, LV_ALIGN_CENTER, LV_PART_MAIN);

    lv_group_t *g = lv_group_create();
    lv_group_add_obj(g, scr);
    lv_indev_set_group(my_indev, g);

    lv_obj_add_event_cb(scr, my_event_cb, LV_EVENT_CLICKED, NULL);

    lv_scr_load_anim(scr, LV_SCR_LOAD_ANIM_MOVE_TOP, 300, 0, true);
}